/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.hiof.moraa.server.service.model;

/**
 * In Ant+ system GPS
 * Lat: is degree unit
 * Lng: is degree unit
 * Alt: sea level height by meters
 * @author Bergy
 */
public class AntPlusGpsGeoPoint extends GeoPoint{

    public AntPlusGpsGeoPoint(double lat, double lng, double altitude) {
        super(lat, lng, altitude);
    }
        
    @Override
    public CartesianCoordinate toCartersianCartesianCoordinate() {
        double radius = convertSeaLevelHeight2EarthRadius(this.getAltitude());
        
        double x = radius * Math.cos(getLatInRadian()) * Math.sin(getLngInRadian());
        double y = radius * Math.sin(getLatInRadian());
        double z = radius * Math.cos(getLatInRadian()) * Math.cos(getLngInRadian());
        return new CartesianCoordinate(x, y, z);
    }

    private double convertSeaLevelHeight2EarthRadius(double altitude) {
        return altitude + 6370000;
    }
    
}
